<template>
  <div class="body">
    <!-- 标题 -->
    <v-head></v-head>
    <!-- 个人中心 -->
    <Row>
        <i-col span="3" class="usercenterleft">
          <router-link to="/userinfo" class="usercenterrouter">个人信息</router-link>
          <router-link to="/userorders" class="usercenterrouter">所有订单</router-link>
          <router-link to="/purchasedstandard" class="usercenterrouter">已购买标准</router-link>
        </i-col>
        <i-col span="21">
          <Row class="restand">
            <div class="standardt">
              用户中心
            </div>
          </Row>
          <Row class="userfirst">
            <i-col span="4">
              <div class="userimageb">
                <img class="userimg" src="../../static/image/userimage.png" alt="">
                <span class="username">{{ username }}</span>
              </div>
            </i-col>
            <i-col span="18" class="userfirsecol">
              <div class="useryue">
                <span class="infofirone">余额:</span>
                <span class="infofir">{{ tatolDeposit }}</span>
                <!-- <span class="infofirone">折扣:</span>
                <span class="infofir">9.5</span>
                <span class="infofirone">等级:</span>
                <span class="infofir">二级</span> -->
                <span class="infofirone">积分:</span>
                <span class="infofir">{{ tatolPoint }}</span>
                <span class="infofironebtn"><i-button type="info" @click="instance('info')">充值</i-button></span>
                <span class="infofironebtn"><i-button type="info" @click="changePassword()">修改密码</i-button></span>
              </div>
            </i-col>
          </Row>
          <router-view></router-view>
        </i-col>
    </Row>
    <!-- <Row class="restand">
    <i-col class="standkepudigndan" span="17">
      <div class="standardt">
        所有订单
      </div>
      <div class="result">
        <Row class="orderrow" v-for="(item,index) in results" :key="index">
          <i-col span="2">
            <div class="orderimg" alt=""></div>
          </i-col>
          <i-col span="20">
            <div @click="getOrderDetail(item.id)" class="itemtitle">{{ item.orderSn }}</div>
            <div class="itemics">总金额:<span class="itemicss">{{ item.totalAmount }}</span><span class="itemicss">总页数:</span><span class="itemcsss">{{ item.standardPages }}</span></div>
          </i-col>
          <i-col span="2"><span @click="getOrderDetail(item.id)" class="itemdetail">查看详情</span></i-col>
        </Row>
        <Page :total="dataCount" :page-size="pageSize" show-total @on-change="changepage" v-if="showPage" class-name="changepage" show-elevator />
      </div>
    </i-col>
    </Row> -->
    <!-- 底部 -->
    <v-foot></v-foot>
    <Back-top></Back-top>
  </div>
</template>
<script>
import {neturl} from '../assets/js/common'
export default {
  name: 'seniorsearch',
  data () {
    return {
      msg: '内蒙古标准文献服务平台',
      theme1: 'light',
      byname: 'bymenu',
      value: '',
      results: [],
      model1: '',
      keyword: '',
      dataCount: 0,
      pageSize: 10,
      pageNum: 1,
      showPage: false,
      userinfo: '',
      islogin: false,
      islog: true,
      username: '',
      tatolDeposit: '',
      tatolPoint: ''
    }
  },
  methods: {
    getSearchResult () {
      let uploadcc = { data: '{page: ' + this.pageNum + ', pagesize: ' + this.pageSize + ', memid:"' + this.userinfo.userId + '"}' }
      this.$axios.post(neturl + '/by/order/getByUserId?token=' + this.userinfo.token + '&loginMark=' + this.userinfo.loginMark, uploadcc
      ).then(res => {
        // console.log(res)
        this.results = res.data.data.result
        this.dataCount = res.data.data.records
        this.showPage = true
      })
    },
    changepage (value) {
      this.pageNum = value
      this.getSearchResult()
    },
    getOrderDetail (id) {
      // console.log(id)
      let routeData = this.$router.resolve({path: '/orderdetail', query: {id: id}})
      window.open(routeData.href, '_blank')
    },
    // 修改密码
    changePassword () {
      let routeUrl = this.$router.resolve({path: '/changepassword'})
      window.open(routeUrl.href, '_blank')
    },
    instance (type) {
      // const title = '对话框的标题'
      const content = '<p>请联系管理员</p>'
      switch (type) {
        case 'info':
          this.$Modal.info({
            // title: title,
            content: content
          })
          break
      }
    }
  },
  created () {
    // this.model1 = this.cityList[0].value
    this.userinfo = this.$cookie.get('user')
    if (this.userinfo === null) {
      this.$router.push('/login')
    }
    this.userinfo = JSON.parse(this.userinfo)
    // 已登录
    if (this.userinfo != null) {
      this.islogin = true
      this.islog = false
      this.username = this.userinfo.realName
    }
    // 获取用户信息
    // let upload = { data: '', token: this.userinfo.token, loginMark: this.userinfo.loginMark }
    this.$axios.get(neturl + '/by/adms/user/info?token=' + this.userinfo.token + '&loginMark=' + this.userinfo.loginMark
    ).then(res => {
      // console.log(res)
      let u = res.data.data.baseinfo
      this.tatolDeposit = u.tatolDeposit
      this.tatolPoint = u.tatolPoint
    })
    // 分页获取订单信息
    // this.getSearchResult()
    // let upload = { data: this.userinfo.userId }
    // let uploadcc = { data: '{page: ' + this.pageNum + ', pagesize: ' + this.pageSize + ', memid:"' + this.userinfo.userId + '"}' }
    // this.$axios.post(neturl + '/by/order/getByUserId?token=' + this.userinfo.token + '&loginMark=' + this.userinfo.loginMark, uploadcc
    // ).then(res => {
    //   console.log(res)
    //   this.results = res.data.data.result
    //   // todo 分页
    //   this.dataCount = res.data.data.records
    //   this.showPage = true
    // })
  }
}
</script>

<style scoped>
  @import '../assets/css/usercenter.css';
</style>
